package com.example.springmvcwork.interceptors;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;
import org.springframework.web.servlet.HandlerInterceptor;



public class interceptor implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        HttpSession session = request.getSession();



        if(((HttpSession) session).getAttribute("username")!=null){
            return true;
        }

        else{

            request.getRequestDispatcher("/upload/enter").forward(request,response);
            return false;
        }

    }

}
